<div class="bg-light lter b-b wrapper-md">
    <h4 class="m-n font-thin">财务报表</h4>
</div>
<div class="wrapper" ng-controller="ordersHistoryCtrl">
    <div class="panel panel-default padder-v padder-md">
        <div class="wrapper panel-body b-a m-b-sm padder-v">
            <div class="col-sm-9">
                <form class="form-inline">
                    <div class="block m-t-sm">
                        <label class="control-label">查询时间</label>
                        <div class="input-group inline" ng-controller="DatepickerDemoCtrl">
                            <div class="input-group  no-padder m-n w-lg">
                                <input type="text" class="input-sm form-control" placeholder="请输入开始日期" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy-MM-dd" ng-model="ordersHistory.startTime"
                               alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" close-text="关闭" clear-text="清空" current-text="今天" disabled/>
                                <span class="input-group-btn ">
                                    <button type="button" class="input-sm btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                                </span>
                            </div>
                        </div>
                        <div class="input-group inline" ng-controller="DatepickerDemoCtrl">
                            <div class="input-group  no-padder m-n w-lg">
                                <input type="text" class="input-sm form-control" placeholder="请输入结束日期" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy-MM-dd" ng-model="ordersHistory.endTime"
                               alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" close-text="关闭" clear-text="清空" current-text="今天" min-date="ordersHistory.startTime" disabled/>
                                <span class="input-group-btn ">
                                    <button type="button" class="input-sm btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group block m-t-sm">
                        <div class="form-group inline">
                            <label class="control-label">交易编号</label>
                            <input type="text inline" ng-model="ordersHistory.transactionNumber" class="input-sm form-control">
                        </div>
                        <div class="form-group inline">
                            <label class="control-label">订单编号</label>
                            <input type="text inline" ng-model="ordersHistory.orderNumber" class="input-sm form-control">
                        </div>
                        <div class="form-group inline">
                            <label class="control-label">店铺名称</label>
                            <select class="input-sm form-control" ng-model="ordersHistory.shopId">
                                <option  value="">－－请选择－－</option>
                                <option ng-repeat="s in shopSelectList" value="{{s.id}}">{{s.name}}</option>
                            </select>
                        </div>
                    </div>
                    <button class="btn btn-md btn-default" ng-click="query()">查询</button>
                </form>
            </div>
            <div class="col-sm-1 pull-right no-padder">
                <div class="text-right">
                    <button class="btn btn-success m-n" ng-click="exportData()">导出报表</button>
                </div>
            </div>
        </div>
        <div class="fa-border">
            <table class="table m-b-none table-striped table-responsive">
                <thead>
                    <tr>
                        <th>行业</th>
                        <th>店铺名称</th>
                        <th>编号详情</th>
                        <th>订单金额</th>
                        <th>优惠券名称</th>
                        <th>分润金额</th>
                        <th>流水金额</th>
                        <th>总让利金额</th>
                        <th>商家得到金额</th>
                        <th>利润</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="item in list">
                        <td>{{item.industryFullName}}</td>
                        <td>{{item.shopName}}</td>
                        <td>
                            <span>订单编号：{{item.orderNumber}}<br></span>
                            <span>店铺订单编号：{{item.shopOrderNumber}}<br></span>
                            <span ng-if="item.payWay == 0">交易编号：{{item.transactionNumber}}<br></span>
                            <span>下单时间:{{item.createdTime}}</span>
                        </td>
                        <td>
                            <span>订单金额：{{item.realMoney | number:2}} 元<br></span>
                            <span>优惠金额：{{item.couponsMoney | number:2}} 元<br></span>
                            <span>配送费：{{item.postage | number:2}} 元<br></span>
                            <span>支付金额：{{item.payMoney | number:2}} 元<br></span>
                            <span ng-if="item.payWay == 0">支付方式：微信<br></span>
                            <span ng-if="item.payWay == 1">支付方式：现金分<br></span>
                            <span ng-if="item.payWay == 2">支付方式：收益分<br></span>
                            <span>差价：{{item.priceDifference | number:2}} 元</span>
                        </td>
                        <td>
                            <label ng-if="item.couponsName != null">
                                <span ng-if="item.couponsType == 0">{{item.couponsName}}(平台)</span>
                                <span ng-if="item.couponsType == 1">{{item.couponsName}}(商户)</span>
                                <i class="m-l-xs fa fa-question-circle text-muted pos-rlt h6" popover-placement="right"
                                   popover="{{item.introduce}}" popover-trigger="mouseenter"></i>
                            </label>
                            <label ng-if="item.couponsName == null">
                                <span>无使用优惠券</span>
                            </label>
                        </td>
                        <td>
                            <span>用户分润：{{item.shareBenefitMoney | number:2}} 元<br></span>
                            <span>代理分润：{{item.agencyBenefit | number:2}} 元</span>
                        </td>
                        <td>
                            <span>用户流水：{{item.referrerMoney | number:2}} 元<br></span>
                            <span>代理流水：{{item.agencyAccount | number:2}} 元</span>
                        </td>
                        <td>{{item.profitMoney | number:2}} 元</td>
                        <td>{{item.shopMoney | number:2}} 元</td>
                        <td>
                            <span>毛利：{{item.grossMargin | number:2}} 元<br></span>
                            <span>毛利率：{{item.grossMarginRate | number:2}}%</span>
                        </td>
                        <td class="t-btns text-left">
                            <a class="btn btn-sm btn-success" ui-sref="app.goodsData({id:item.id})" target="_blank">查看商品数据</a>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div ng-if="list.length<=0 && !app.loading" class="padder-v text-center">
                <span class="h6">~未搜索到任何数据~</span>
            </div>
            <div>
                <circle-loading ng-if="app.loading"></circle-loading>
            </div>
        </div>
        <footer class="panel-footer">
            <div class="row">
                <div class="col-sm-4 hidden-xs">
                </div>
                <div class="col-sm-4 text-center">
                    <small class="text-muted inline m-t-sm m-b-sm">显示第 {{startRow}} 至 {{endRow}} 项结果，共 {{totalItems}} 项</small>
                </div>
                <div class="col-sm-4 text-right text-center-xs">
                    <pagination boundary-links="true" total-items="totalItems" ng-model="currentPage"
                                ng-change="pageChanged()" max-size="{{maxPageRow}}" class="pagination-sm m-t-none m-b"
                                previous-text="上一页" next-text="下一页"
                                first-text="首页" last-text="尾页"></pagination>
                </div>
            </div>
        </footer>
    </div>
</div>